﻿
import { Dialog } from 'primeng/components/dialog/dialog';
import { Component, Injector, ViewChild, OnInit } from '@angular/core';
import { appModuleAnimation } from '@shared/animations/routerTransition';
import { AppComponentBase } from '@shared/common/app-component-base';
import {  WorkStationUpdateOrOutput, PrintEquipmentServiceProxy, PrintEquipmentDto, UpdatePrintEquipment, CreatePrintEquipment, CompanyDto, OrganizationUnitServiceProxy, ComboboxItemDto } from '@shared/service-proxies/service-proxies';
import { Table } from 'primeng/components/table/table';
import * as _ from 'lodash';
import { finalize } from 'rxjs/operators';


@Component({
    selector : 'app-contact',
    templateUrl: './setting.component.html',
    styleUrls: ['./setting.component.less'],
    animations: [appModuleAnimation()]
})
export class SettingComponent extends AppComponentBase implements OnInit  {

    myPrinterInfo = '';
    printerCombobox :ComboboxItemDto[] = [];
    newPrinterId = '';

    constructor(
        injector: Injector,
        private _printEquipmentServiceProxy: PrintEquipmentServiceProxy
        ) 
        {
            super(injector);            
        }

    
    
    cols: any[];
    ngOnInit(): void {
        this.getMyPrinterInfo();
        this.getAllCanUsingPrinterForComboBox();
    }

    getMyPrinterInfo()
    {
        this._printEquipmentServiceProxy.getMyPrinterInfo().subscribe((result)=>{
           this.myPrinterInfo = result;
        });
    }

    getAllCanUsingPrinterForComboBox()
    {
        this._printEquipmentServiceProxy.getAllCanUsingPrinterForComboBox().subscribe((result)=>{
            this.printerCombobox = result;
         });
    }

    saveMyPrinter()
    {
        let newPrinterId = Number
        this._printEquipmentServiceProxy.saveMyPrinter(Number(this.newPrinterId)).subscribe(()=>{
           this.getMyPrinterInfo();
         });
    }
    
}
